/*
 * Bsp_Beep.c
 *
 *  Created on: Mar 29, 2025
 *      Author: Administrator
 */
#include "Bsp_Beep.h"

uint16_t Beep_Time = 0;
uint8_t Beep_state = 0;


static void Set_Beep_Time(uint16_t time){

	Beep_Time = time;
}

static uint16_t Get_Beep_Time(void){

	return Beep_Time;
}

static void Set_Beep_State(uint8_t state){

	Beep_state = state;
}

static uint8_t Get_Beep_State(void){

	return Beep_state;
}

void Beep_On_Time(uint16_t time){

	if(time == BEEP_ON_ALWAYS){
		BEEP_ON();
		Set_Beep_State(BEEP_ON_ALWAYS);
		Set_Beep_Time(0);
	}
	else if(time == BEEP_OFF_ALWAYS){
		BEEP_OFF();
		Set_Beep_State(BEEP_OFF_ALWAYS);
		Set_Beep_Time(0);
	}
	else{
		if(time >=  10){
			Set_Beep_State(BEEP_ON_DELAY);
			Set_Beep_Time(time /10);
			BEEP_ON();
		}
	}
}



void Beep_Timeout_Close_Handle(void){

	if(Get_Beep_State() == BEEP_ON_DELAY){
		if(Get_Beep_Time()){
			Beep_Time --;
		}
		else{
			BEEP_OFF();
			Set_Beep_State(BEEP_OFF_ALWAYS);
		}
	}
}
